	function add_new_brn(){
		var vFBRNCODE = document.getElementById('FBRNCODE').value;
		var vFDEPTCD = document.getElementById('FDEPTCD').value;
		
		var vtodepttmp = document.getElementById('TODEPTtmp').value;
		var branhcode = document.getElementById('BRNtmp').value;
		var deptcode = document.getElementById('DPTtmp').value;
		
		var branhlist = document.getElementById('TODEPT').value;
		var branh_arr = branhlist.split('#');
		var stringbranh='';
		
		var num=0;
		
		if(vtodepttmp == 'ALL'){
			document.getElementById('TODEPT').value='';
			document.getElementById('TODEPT').value='ALL';
			num=1;
		}else{
			if(vtodepttmp == 'BRN'){
				document.getElementById('TODEPT').value='';
				document.getElementById('TODEPT').value='BRN';
				num=1;
			}
		}
		
		//alert(branhlist.replace('#',''));
		if(branhlist.replace('#','')=='ALL'){
			num=1;	
		}
		if(branhlist.replace('#','')=='BRN'){
			num=1;	
		}
		
		if(vFBRNCODE == branhcode){
			if(vFDEPTCD == deptcode){
				num=1;
			}
		}
		
		if(vFBRNCODE == ''){
			num=1;
		}
		
		for(i in branh_arr){
			if (branh_arr[i]==branhcode+deptcode){
				num=1;
				break;
			}
		}
		if(num==0){
			stringbranh = branhcode+deptcode;
			document.getElementById('TODEPT').value = document.getElementById('TODEPT').value + stringbranh +"#";
		}
	}
	
	function delete_brn(){
		var i;
		var num=0;
		var vtodepttmp = document.getElementById('TODEPTtmp').value;
		var branhcode = document.getElementById('BRNtmp').value;
		var deptcode = document.getElementById('DPTtmp').value;
		var branhlist = document.getElementById('TODEPT').value;
		var branh_arr = branhlist.split('#');
		
		if(branhlist.replace('#','')==vtodepttmp){
			document.getElementById('TODEPT').value='';
			num=1;
		}
		
		if(branhlist.replace('#','')==branhcode+deptcode){
			document.getElementById('TODEPT').value='';
			num=1;
		}
		if(num==0){
			for(i in branh_arr){
				if(branh_arr[i]==branhcode+deptcode){	
					branhlist = branhlist.replace(branhcode+deptcode+'#','');
				}
			}
			document.getElementById('TODEPT').value = branhlist;
		}
	}
	
	function valbutton_branh(thisform,objname) {
		var objradio = thisform.radioTK;
		var radioLength = objradio.length;
		var id, i;
		if(!radioLength){
			id = objradio.value;		
		}else{
			for(i = 0; i < radioLength; i++){
				if(thisform.radioTK[i].checked){
					id = thisform.radioTK[i].value;
					break;
				}
			}
		}
		var name = id.split('-');	
		//alert(objname);
		var lblname = objname.split('-');
		var obj1 = window.opener.document.getElementById(lblname[0]);
		var obj2 = window.opener.document.getElementById(lblname[1]);
		if(obj1){
			obj1.value = name[0];
			var findcbodpt = window.opener.document.getElementById("findcbodpt");
			if(findcbodpt){
				findcbodpt.click();	
			}
		}
		if(obj2){
			obj2.value = name[1];
		}
		
		window.close();
	}
	
	function imposeMaxLength(Event, Object, MaxLen){
			return (Object.value.length <= MaxLen)||(Event.keyCode == 8 || Event.keyCode==46||(Event.keyCode>=35&&Event.keyCode<=40));
	}